package com.ideaaedi.springcloud.jd.yourbiz.controller;

import com.ideaaedi.springcloud.jd.commonds.entity.PageInfo;
import com.ideaaedi.springcloud.jd.commonds.entity.Result;
import com.ideaaedi.springcloud.jd.commonds.entity.user.vo.req.SysMenuListReqVO;
import com.ideaaedi.springcloud.jd.commonds.entity.user.vo.resp.SysMenuDetailRespVO;
import com.ideaaedi.springcloud.jd.commonds.entity.user.vo.resp.SysMenuListRespVO;
import com.ideaaedi.springcloud.jd.yourbiz.feignclient.UserFeignClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 测试
 */
@RestController
@RequestMapping("/test")
@Api(tags = "biz - 测试")
public class TestController {
    
    @Resource
    UserFeignClient userFeignClient;
    
    /**
     * 测试能否访问进当前服务
     *
     * @return 更新后的菜单详情
     */
    @PostMapping("/hello")
    @ApiOperation(value = "测试能否访问进当前服务")
    public Result<String> hello() {
        return Result.success("你好，陌生人~");
    }
    
    /**
     * feign调用jd-user服务的菜单list
     *
     * @param req 参数
     *
     * @return 菜单list
     */
    @PostMapping("/menu/list")
    @ApiOperation(value = "feign调用jd-user服务的菜单list")
    public Result<PageInfo<SysMenuListRespVO>> list(@RequestBody SysMenuListReqVO req) {
        return userFeignClient.list(req);
    }
    
    /**
     * feign调用jd-user服务的菜单detail
     *
     * @param id 要查询数据的id
     *
     * @return 菜单详情
     */
    @PostMapping("/menu/detail/{id}")
    @ApiOperation(value = "feign调用jd-user服务的菜单detail")
    public Result<SysMenuDetailRespVO> detail(@PathVariable("id") Long id) {
        return userFeignClient.detail(id);
    }
    
}
